package com.aspose.cells;

import java.util.ArrayList;
import java.util.Iterator;

class zarf {
   private zcfx a;
   private zapt b;

   public zarf(zapt var1) {
      this.b = var1;
   }

   zarf(zapt var1, zcfx var2) {
      this.b = var1;
      this.a = var2;
   }

   void a(zcfx var1) throws Exception {
      this.a = var1;
      this.b();
      var1.b("office:automatic-styles");
      this.c();
      this.d();
      this.e();
      this.a();
      this.f();
      this.g();
      var1.b();
   }

   private void b() throws Exception {
      this.a.b("office:font-face-decls");
      Iterator var1 = this.b.b.iterator();

      while(var1.hasNext()) {
         zapw var2 = (zapw)var1.next();
         this.a(var2);
      }

      this.a.b();
   }

   private void c() throws Exception {
      Iterator var1 = this.b.c.iterator();

      while(var1.hasNext()) {
         zaps var2 = (zaps)var1.next();
         this.a(var2);
      }

   }

   private void d() throws Exception {
      Iterator var1 = this.b.d.iterator();

      while(var1.hasNext()) {
         zaqd var2 = (zaqd)var1.next();
         this.a(var2);
      }

   }

   private void e() throws Exception {
      Iterator var1 = this.b.a.getWorksheets().iterator();

      while(var1.hasNext()) {
         Worksheet var2 = (Worksheet)var1.next();
         this.a(var2);
      }

   }

   void a() throws Exception {
      Iterator var1 = this.b.f.iterator();

      while(var1.hasNext()) {
         zapq var2 = (zapq)var1.next();
         if (var2.c.getName() == null) {
            this.a(var2);
         }
      }

   }

   private void f() throws Exception {
      ArrayList var1 = this.b.a.getWorksheets().z();

      for(int var2 = 0; var2 < var1.size(); ++var2) {
         Font var3 = (Font)var1.get(var2);
         this.a(var3.j(), var3);
      }

   }

   private void g() throws Exception {
      if (this.b.g != null && this.b.g.size() > 0) {
         Iterator var1 = this.b.g.iterator();

         while(var1.hasNext()) {
            zapu var2 = (zapu)var1.next();
            this.a(var2);
         }
      }

   }

   private void a(zapw var1) throws Exception {
      this.a.b("style:font-face");
      this.a.a("style", "name", (String)null, var1.a());
      this.a.a("svg", "font-family", (String)null, var1.a());
      this.a.b();
   }

   private void a(zaps var1) throws Exception {
      this.a.b("style:style");
      this.a.a("style", "name", (String)null, var1.b());
      this.a.a("style", "family", (String)null, "table-column");
      this.a.b("style:table-column-properties");
      this.a.a("fo", "break-before", (String)null, zaqf.a(var1.c()));
      this.a.a("style", "column-width", (String)null, zaqh.b(var1.a()) + "in");
      this.a.b();
      this.a.b();
   }

   private void a(zaqd var1) throws Exception {
      this.a.b("style:style");
      this.a.a("style", "name", (String)null, var1.a());
      this.a.a("style", "family", (String)null, "table-row");
      this.a.b("style:table-row-properties");
      this.a.a("style", "row-height", (String)null, zaqh.b(var1.b()) + "in");
      this.a.a("fo", "break-before", (String)null, zaqf.a(var1.d()));
      this.a.a("style", "use-optimal-row-height", (String)null, zaqh.a(var1.c()));
      this.a.b();
      this.a.b();
   }

   private void a(Worksheet var1) throws Exception {
      this.a.b("style:style");
      int var2 = var1.getIndex() + 1;
      this.a.a("style", "name", (String)null, "ta" + var2);
      this.a.a("style", "family", (String)null, "table");
      this.a.a("style", "master-page-name", (String)null, "PageStyle_5f_" + var1.getName());
      this.a.b("style:table-properties");
      this.a.a("table", "display", (String)null, var1.isVisible() ? "true" : "false");
      this.a.a("style", "writing-mode", (String)null, "lr-tb");
      this.a.b();
      this.a.b();
   }

   void a(zapq var1) throws Exception {
      this.a.b("style:style");
      this.a.a("style", "name", (String)null, var1.a());
      this.a.a("style", "family", (String)null, "table-cell");
      if (!zaqh.e(var1.b())) {
         this.a.a("style", "parent-style-name", (String)null, var1.b());
      }

      if (!zaqh.e(var1.a)) {
         this.a.a("style", "data-style-name", (String)null, var1.a);
      }

      Style var2 = var1.c;
      if (var1.g || var1.f || var1.e || var1.d) {
         this.a(var1, var1.c);
      }

      if (var1.b != null) {
         this.a(var1.b, true);
      }

      this.a.b();
   }

   private void a(int var1, Font var2) throws Exception {
      this.a.b("style:style");
      this.a.a("style", "name", (String)null, "T" + var1);
      this.a.a("style", "family", (String)null, "text");
      this.a(new zapx(var2), false);
      this.a.b();
   }

   private void a(zapu var1) throws Exception {
      if (var1 != null) {
         if (var1.u != null && var1.u.size() > 0) {
            Iterator var2 = var1.u.iterator();

            while(var2.hasNext()) {
               zaqy var3 = (zaqy)var2.next();
               this.a.b("style:style");
               int var4 = var1.i.getIndex() + var3.a.x() + 1;
               this.a.a("style", "name", (String)null, "S" + var4);
               this.a.a("style", "family", (String)null, "graphic");
               this.a(var3);
               this.a(var3.a.aa().g(), new Style(var3.a.L()));
               this.a.b();
            }
         }

      }
   }

   private void a(zaqy var1) throws Exception {
      if (var1 != null) {
         Shape var2 = var1.a;
         this.a.b("style:graphic-properties");
         zbtz var3 = var2.aa();
         this.a.a("fo", "wrap-option", (String)null, zaqh.b(var3.d));
         if (var3.d) {
            this.a.a("draw", "textarea-vertical-align", (String)null, zaqh.c(var3.h()));
            this.a.a("draw", "textarea-horizontal-align", (String)null, zaqh.d(var3.g()));
         }

         FillFormat var4 = var2.getFill();
         if (var4.getImageData() != null) {
            switch(var4.getType()) {
            case 4:
               this.a.a("draw", "fill", (String)null, "bitmap");
            default:
               int var5 = var2.M().getIndex() + var2.x() + 1;
               this.a.a("draw", "fill-image-name", (String)null, "D" + var5);
               if (!var2.aj()) {
                  this.a.a("style", "repeat", (String)null, "stretch");
               }
            }
         }

         MsoLineFormat var7 = var2.getLineFormat();
         if (var7.isVisible()) {
            this.a.a("draw", "stroke", (String)null, "solid");
            this.a.a("svg", "stroke-width", (String)null, zaqh.a((double)var2.L().L(), (int)var7.getWeight()));
            this.a.a("svg", "stroke-color", (String)null, zaqh.b(var7.getForeColor()));
            this.a.a("svg", "stroke-opacity", (String)null, zaqh.d(var7.c()));
         }

         MsoTextFrame var6 = var2.getTextFrame();
         if (!var6.isAutoMargin()) {
            this.a.a("fo", "padding-top", (String)null, zaqh.a((double)var2.L().L(), var6.d()));
            this.a.a("fo", "padding-bottom", (String)null, zaqh.a((double)var2.L().L(), var6.e()));
            this.a.a("fo", "padding-left", (String)null, zaqh.a((double)var2.L().L(), var6.b()));
            this.a.a("fo", "padding-right", (String)null, zaqh.a((double)var2.L().L(), var6.c()));
            this.a.a("draw", "auto-grow-width", (String)null, "false");
            this.a.a("draw", "auto-grow-height", (String)null, "false");
         }

         this.a.b();
      }
   }

   private void a(zapq var1, Style var2) throws Exception {
      this.a.b("style:table-cell-properties");
      if (var1.f) {
         if (var2.f()) {
            this.a(var2.getBorders().getByBorderType(1), "fo", "border-left");
            this.a(var2.getBorders().getByBorderType(2), "fo", "border-right");
            this.a(var2.getBorders().getByBorderType(4), "fo", "border-top");
            this.a(var2.getBorders().getByBorderType(8), "fo", "border-bottom");
            this.a(var2.getBorders().getByBorderType(32), "style", "diagonal-bl-tr");
            this.a(var2.getBorders().getByBorderType(16), "style", "diagonal-tl-br");
         } else {
            this.a.a("style", "border", (String)null, "none");
         }
      }

      int var3 = var2.getHorizontalAlignment();
      String var5;
      if (var1.g) {
         int var4 = var2.getRotationAngle();
         var5 = null;
         String var6 = "ltr";
         if (var4 != 0) {
            if (var4 == 255) {
               var6 = "ttb";
               var5 = "0";
            } else if (var4 < 0) {
               var4 += 360;
               var5 = com.aspose.cells.b.a.zo.a(var4);
            } else {
               var5 = com.aspose.cells.b.a.zo.a(var4);
            }

            this.a.a("style", "rotation-angle", (String)null, var5);
            this.a.a("style", "rotation-align", (String)null, "none");
            this.a.a("style", "direction", (String)null, var6);
         }

         if (var2.getShrinkToFit()) {
            this.a.a("style", "shrink-to-fit", (String)null, "true");
         }

         if (var2.isTextWrapped()) {
            this.a.a("fo", "wrap-option", (String)null, "wrap");
         }

         String var7 = null;
         int var8 = var2.getVerticalAlignment();
         if (var8 != 5) {
            switch(var8) {
            case 0:
               var7 = "bottom";
               break;
            case 1:
               var7 = "middle";
               break;
            case 9:
               var7 = "top";
            }

            this.a.a("style", "vertical-align", (String)null, var7);
         }

         if (var3 == 4) {
            this.a.a("style", "repeat-content", (String)null, "true");
         }
      }

      if (var1.d) {
         Color var9 = var2.getForegroundColor();
         if (var2.getPattern() != 0 && !var9.isEmpty()) {
            var5 = zaqh.b(var9);
            this.a.a("fo", "background-color", (String)null, var5);
         } else {
            this.a.a("fo", "background-color", (String)null, "transparent");
         }
      }

      if (var1.e) {
         boolean var10 = var2.getName() == null || var2.o();
         if (var10) {
            if (var2.isFormulaHidden()) {
               if (var2.isLocked()) {
                  this.a.a("style", "cell-protect", (String)null, "protected formula-hidden");
               } else {
                  this.a.a("style", "cell-protect", (String)null, "formula-hidden");
               }
            } else if (var2.isLocked()) {
               this.a.a("style", "cell-protect", (String)null, "protected");
            } else {
               this.a.a("style", "cell-protect", (String)null, "none");
            }
         }
      }

      this.a.b();
      if (var1.g) {
         this.a(var3, var2);
      }

   }

   void a(Border var1, String var2, String var3) throws Exception {
      if (var1.getLineStyle() != 0) {
         String var4 = zaqh.b(var1.getLineStyle());
         if (!var1.a.a()) {
            var4 = var4 + zaqh.b(var1.getColor());
         }

         this.a.a(var2, var3, (String)null, var4);
      }
   }

   private void a(int var1, Style var2) throws Exception {
      this.a.b("style:paragraph-properties");
      String var3 = null;
      switch(var1) {
      case 1:
      case 2:
         var3 = "center";
         break;
      case 3:
      case 6:
         var3 = "justify";
         break;
      case 4:
      case 7:
         var3 = "start";
      case 5:
      default:
         break;
      case 8:
         var3 = "end";
      }

      String var4 = null;
      if (var1 == 7) {
         double var5 = (double)var2.getIndentLevel() * 0.353D;
         var4 = zaqh.b(var5) + "cm";
      }

      if (var4 != null) {
         if (var3 != null) {
            this.a.a("fo", "text-align", (String)null, var3);
            this.a.a("fo", "margin-left", (String)null, var4);
         } else {
            this.a.a("fo", "margin-left", (String)null, var4);
         }
      } else if (var3 != null) {
         this.a.a("fo", "text-align", (String)null, var3);
      }

      this.a.b();
   }

   private void a(zapx var1, boolean var2) throws Exception {
      int var3 = var1.i();
      this.a.b("style:text-properties ");
      if (var2 || !zaqh.e(var1.g()) && var1.a.f(13)) {
         this.a.a("style", "font-name", (String)null, var1.g());
         this.a.a("style", "font-name-asian", (String)null, var1.g());
      }

      if (var1.b()) {
         this.a.a("fo", "font-weight", (String)null, "bold");
         this.a.a("style", "font-weight-asian", (String)null, "bold");
         this.a.a("style", "font-weight-complex", (String)null, "bold");
      } else {
         this.a.a("fo", "font-weight", (String)null, "normal");
         this.a.a("style", "font-weight-asian", (String)null, "normal");
         this.a.a("style", "font-weight-complex", (String)null, "normal");
      }

      if (var1.c()) {
         this.a.a("fo", "font-style", (String)null, "italic");
         this.a.a("style", "font-style-asian", (String)null, "italic");
         this.a.a("style", "font-style-complex", (String)null, "italic");
      } else {
         this.a.a("fo", "font-style", (String)null, "normal");
         this.a.a("style", "font-style-asian", (String)null, "normal");
         this.a.a("style", "font-style-complex", (String)null, "normal");
      }

      if (var1.d()) {
         this.a.a("style", "text-line-through-style", (String)null, "solid");
      } else {
         this.a.a("style", "text-line-through-style", (String)null, "none");
      }

      if (var1.h() != 0.0D) {
         this.a.a("fo", "font-size", (String)null, zaqh.a(var1.h()) + "pt");
         this.a.a("style", "font-size-asian", (String)null, zaqh.a(var1.h()) + "pt");
         this.a.a("style", "font-size-complex", (String)null, zaqh.a(var1.h()) + "pt");
      }

      if (!var1.b) {
         String var4 = zaqh.b(var1.a());
         this.a.a("fo", "color", (String)null, var4);
      } else {
         this.a.a("style", "use-window-font-color", (String)null, "true");
      }

      if (var3 != 2 && var3 != 4) {
         if (var3 != 1 && var3 != 3) {
            this.a.a("style", "text-underline-style", (String)null, "none");
         } else {
            this.a.a("style", "text-underline-style", (String)null, "solid");
            this.a.a("style", "text-underline-type", (String)null, "single");
         }
      } else {
         this.a.a("style", "text-underline-style", (String)null, "solid");
         this.a.a("style", "text-underline-type", (String)null, "double");
      }

      if (var1.f()) {
         this.a.a("style", "text-position", (String)null, "33% 58%");
      }

      if (var1.e()) {
         this.a.a("style", "text-position", (String)null, "-33% 58%");
      }

      this.a.b();
   }
}
